package com.letoken.platform.pub.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 排序定义枚举
 */
public enum EnumSort {

    ASC("asc", "升序"),
    DESC("desc", "倒序");

    private String value;
    private String text;

    private static Map<String, EnumSort> pool = new HashMap<>();


    EnumSort(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public static EnumSort valueOf(int value) {
        return pool.get(String.valueOf(value));
    }

    public String getValue() {
        return this.value;
    }

    public String getText() {
        return text;
    }

    public static boolean isSupport(String val) {
        for (EnumSort openState : values()) {
            if (openState.getValue().equals(val)) {
                return true;
            }
        }
        return false;
    }

    public static String getText(String val) {
        for (EnumSort openState : values()) {
            if (openState.getValue().equals(val)) {
                return openState.getText();
            }
        }
        return "";
    }

}
